# -*- coding:utf-8 -*-
# 测试pr
import math
import random
import sys
from threading import Timer

import pygame
# 全局定义
from pygame.constants import K_RIGHT, K_DOWN, K_UP, K_LEFT

from bullet.bullet_line import BulletLine
from constant import SCREEN_X, SCREEN_Y, FPS, BOARD_SIZE, FOOD_CONV_SIZE, SCREEN_Y_DIVIDE, SCREEN_X_DIVIDE
from floor import Floor
from food import Food
from snake_ai import SnakeAi
from snake_player import SnakePlayer

screen = None
showDialog = False
POWER = False
SPEEDING = False


# FOOD_RECT = 0, 0


def show_text(screen, pos, text, color, font_bold=False, font_size=60, font_italic=False):
    # 获取系统字体，并设置文字大小
    cur_font = pygame.font.SysFont("SimHei", font_size)
    # 设置是否加粗属性
    cur_font.set_bold(font_bold)
    # 设置是否斜体属性
    cur_font.set_italic(font_italic)
    # 设置文字内容
    text_fmt = cur_font.render(text, 1, color)
    # 绘制文字
    screen.blit(text_fmt, pos)


def power_reset():
    global POWER
    POWER = False


def power_is_overwhelming():
    global POWER
    POWER = True
    a = Timer(2, power_reset)
    a.start()


def funShowDialog():
    global showDialog
    showDialog = True
    print("执行了一次，啦啦啦")
    a = Timer(5, funDismissDialog)
    a.start()


def funDismissDialog():
    global showDialog
    showDialog = False


def event():
    print("啦啦")


def end_speeding():
    global SPEEDING
    SPEEDING = False


def main():
    pygame.init()

    pygame.mixer.init()
    pygame.mixer.music.load("bgm.mp3")
    pygame.mixer.music.play()
    laser_sound = pygame.mixer.Sound("laser3.wav")
    laser_sound.set_volume(0.1)
    screen_size = (SCREEN_X, SCREEN_Y)
    global screen
    screen = pygame.display.set_mode(screen_size)
    pygame.display.set_caption('Snake')
    clock = pygame.time.Clock()
    scores = 0
    isdead = False
    global SPEEDING
    # global FOOD_RECT
    global POWER
    blink = True

    enemy_step = False
    final_bullet_1 = False

    # 蛇/食物
    global snake_ais

    snake_player = SnakePlayer(pygame)
    food = Food(pygame)
    floor = Floor(pygame)
    bullet_line = BulletLine(pygame)
    bullet_line_y_count = 0
    bullet_line_x_count = 0
    scale = FOOD_CONV_SIZE
    snake_ais = []
    lasers_normal = [[204, 180], [1008, 180], [204, 540], [1008, 540]]
    lasers_normal_use = [[204, 180], [1008, 180], [204, 540], [1008, 540]]
    lasers_attack_timer = [5000, 6000, 7000, 8000]
    random_laser_poi = [0, 1, 2, 3]
    random.shuffle(random_laser_poi)
    current_laser = None
    laser_complete = []

    # LASER_Y = SCREEN_Y
    can_bullet_attack_1 = False
    laser_build = False

    MOVMENT = pygame.USEREVENT
    pygame.time.set_timer(MOVMENT, 10000)

    BULLET_ATTACK_1 = pygame.USEREVENT + 1
    pygame.time.set_timer(BULLET_ATTACK_1, 30000)

    ADD_AI = pygame.USEREVENT + 2
    pygame.time.set_timer(ADD_AI, 45000)

    LASER_DEPLOY = pygame.USEREVENT + 3
    pygame.time.set_timer(LASER_DEPLOY, 30000)

    LASER_ATTACK_1 = pygame.USEREVENT + 4
    laser_attack_signal_1 = False
    laser_attack_signal_1_forward = None
    laser_attack_signal_1_start_poi = None
    laser_attack_signal_1_y = None
    laser_attack_signal_1_x = None

    LASER_ATTACK_2 = pygame.USEREVENT + 5
    laser_attack_signal_2 = False
    laser_attack_signal_2_forward = None
    laser_attack_signal_2_start_poi = None
    laser_attack_signal_2_y = None
    laser_attack_signal_2_x = None

    LASER_ATTACK_3 = pygame.USEREVENT + 6
    laser_attack_signal_3 = False
    laser_attack_signal_3_forward = None
    laser_attack_signal_3_start_poi = None
    laser_attack_signal_3_y = None
    laser_attack_signal_3_x = None

    LASER_ATTACK_4 = pygame.USEREVENT + 7
    laser_attack_signal_4 = False
    laser_attack_signal_4_forward = None
    laser_attack_signal_4_start_poi = None
    laser_attack_signal_4_y = None
    laser_attack_signal_4_x = None

    laser_attack_group = []
    laser_attack_group.append(LASER_ATTACK_1)
    laser_attack_group.append(LASER_ATTACK_2)
    laser_attack_group.append(LASER_ATTACK_3)
    laser_attack_group.append(LASER_ATTACK_4)

    order_number = 0

    while True:
        x, y = snake_player.body[0].left, snake_player.body[0].top
        # print(x, y)
        # print(snake_player.body[0])
        # print(snake_ai.body[0])
        for event in pygame.event.get():
            if event.type == LASER_ATTACK_1:
                laser_attack_signal_1 = True
                laser_attack_signal_1_forward = snake_player.dirction
                laser_attack_signal_1_start_poi = snake_player.body[0]
                laser_attack_signal_1_y = SCREEN_Y
                laser_attack_signal_1_x = SCREEN_X
            if event.type == LASER_ATTACK_2:
                laser_attack_signal_2 = True
                laser_attack_signal_2_forward = snake_player.dirction
                laser_attack_signal_2_start_poi = snake_player.body[0]
                laser_attack_signal_2_y = SCREEN_Y
                laser_attack_signal_2_x = SCREEN_X
            if event.type == LASER_ATTACK_3:
                laser_attack_signal_3 = True
                laser_attack_signal_3_forward = snake_player.dirction
                laser_attack_signal_3_start_poi = snake_player.body[0]
                laser_attack_signal_3_y = SCREEN_Y
                laser_attack_signal_3_x = SCREEN_X
            if event.type == LASER_ATTACK_4:
                laser_attack_signal_4 = True
                laser_attack_signal_4_forward = snake_player.dirction
                laser_attack_signal_4_start_poi = snake_player.body[0]
                laser_attack_signal_4_y = SCREEN_Y
                laser_attack_signal_4_x = SCREEN_X
            if event.type == LASER_DEPLOY:
                if len(laser_complete) != 4:
                    laser_build = True
                    current_laser = lasers_normal[random_laser_poi[order_number]]
                else:
                    pygame.time.set_timer(LASER_DEPLOY, 0)

            if event.type == ADD_AI:
                if len(snake_ais) == 4:
                    pygame.time.set_timer(ADD_AI, 0)
                else:
                    snake_ai = SnakeAi(pygame, 600, 100)
                    snake_ais.append(snake_ai)

            if event.type == BULLET_ATTACK_1:
                can_bullet_attack_1 = True

            if event.type == MOVMENT:
                None
            if event.type == pygame.QUIT:
                sys.exit()
            if event.type == pygame.KEYDOWN:
                snake_player.changedirection(event.key)
                # 死后按space重新
                if event.key == pygame.K_SPACE and isdead:
                    pygame.time.set_timer(BULLET_ATTACK_1, 0)
                    pygame.time.set_timer(ADD_AI, 0)
                    pygame.time.set_timer(LASER_DEPLOY, 0)
                    pygame.time.set_timer(LASER_ATTACK_1, 0)
                    pygame.time.set_timer(LASER_ATTACK_2, 0)
                    pygame.time.set_timer(LASER_ATTACK_3, 0)
                    pygame.time.set_timer(LASER_ATTACK_4, 0)
                    return main()
            if event.type == pygame.KEYDOWN and not isdead:
                if event.key == pygame.K_SPACE:
                    t = Timer(5.0, end_speeding)
                    t.start()
                    SPEEDING = True

        screen.fill((250, 240, 230))
        for floor_x_line in floor.floor_x:
            pygame.draw.line(screen, (245, 222, 179), (floor_x_line, 0), (floor_x_line, SCREEN_Y), 1)
        for floor_y_line in floor.floor_y:
            pygame.draw.line(screen, (245, 222, 179), (0, floor_y_line), (SCREEN_X, floor_y_line), 1)

        if showDialog:
            pygame.draw.rect(screen, (0, 0, 0), (50, 400, 800, 100), 10)
            show_text(screen, (70, 420), "啦啦啦，测试文字", (223, 223, 223), font_size=20)
            # print("执行了一次")

        # 画蛇身 / 每一步+1分
        if not isdead:
            scores += 1
            if enemy_step:
                # snake_ais.move()
                [c.move() for c in snake_ais]
                enemy_step = False
            else:
                enemy_step = True

            snake_player.move()

            # if FOOD_RECT and FOOD_RECT == snake_player.body[0]:
            #     # food.remove()
            #     snake_player.addnode()
            if SPEEDING:
                snake_player.move()
                # if FOOD_RECT and FOOD_RECT == snake_player.body[0]:
                #     # food.remove()
                #     snake_player.addnode()

        for c in snake_ais:
            for index, rect in enumerate(c.body):
                if index == 0:
                    pygame.draw.rect(screen, (77, 88, 99), rect, 0)
                else:
                    pygame.draw.rect(screen, (00, 00, 00), rect, 0)
        if POWER:

            if blink:
                for rect in snake_player.body:
                    pygame.draw.rect(screen, (60, 100, 139), rect, 0)
                blink = False
            else:
                for rect in snake_player.body:
                    pygame.draw.rect(screen, (255, 255, 0), rect, 0)
                blink = True

        else:
            for rect in snake_player.body:
                pygame.draw.rect(screen, (144, 238, 144), rect, 0)

        if not isdead:

            for snake_ai in snake_ais:
                sx, sy = snake_ai.body[0].left, snake_ai.body[0].top
                # print(sx, x)
                if x > sx:
                    snake_ai.changedirection(K_RIGHT)
                    if snake_ai.dirction == pygame.K_LEFT:
                        #     调头
                        if y > sy:
                            snake_ai.changedirection(K_DOWN)
                        else:
                            snake_ai.changedirection(K_UP)
                        snake_ai.move()
                        snake_ai.changedirection(K_RIGHT)
                        snake_ai.move()
                    if x == sx or (x - sx) < 50:
                        if y > sy:
                            snake_ai.changedirection(K_DOWN)
                            if snake_ai.dirction == pygame.K_UP:
                                #     调头
                                if x > sx:
                                    snake_ai.changedirection(K_RIGHT)
                                else:
                                    snake_ai.changedirection(K_LEFT)
                                snake_ai.move()
                                snake_ai.changedirection(K_DOWN)
                                snake_ai.move()
                        else:
                            snake_ai.changedirection(K_UP)
                            if snake_ai.dirction == pygame.K_DOWN:
                                #     调头
                                if x > sx:
                                    snake_ai.changedirection(K_RIGHT)
                                else:
                                    snake_ai.changedirection(K_LEFT)
                                snake_ai.move()
                                snake_ai.changedirection(K_UP)
                                snake_ai.move()
                else:
                    snake_ai.changedirection(K_LEFT)
                    if snake_ai.dirction == pygame.K_RIGHT:
                        #     调头
                        if y > sy:
                            snake_ai.changedirection(K_DOWN)
                        else:
                            snake_ai.changedirection(K_UP)
                        snake_ai.move()
                        snake_ai.changedirection(K_LEFT)
                        snake_ai.move()
                    if x == sx or (sx - x) < 50:
                        if y > sy:
                            snake_ai.changedirection(K_DOWN)
                            if snake_ai.dirction == pygame.K_UP:
                                #     调头
                                if x > sx:
                                    snake_ai.changedirection(K_RIGHT)
                                else:
                                    snake_ai.changedirection(K_LEFT)
                                snake_ai.move()
                                snake_ai.changedirection(K_DOWN)
                                snake_ai.move()
                        else:
                            snake_ai.changedirection(K_UP)
                            if snake_ai.dirction == pygame.K_DOWN:
                                #     调头
                                if x > sx:
                                    snake_ai.changedirection(K_RIGHT)
                                else:
                                    snake_ai.changedirection(K_LEFT)
                                snake_ai.move()
                                snake_ai.changedirection(K_UP)
                                snake_ai.move()

        if not POWER:
            if not isdead:
                for enemy_body in snake_ais:
                    for enemy_block in enemy_body.body:
                        for player_block in snake_player.body:
                            if player_block.colliderect(enemy_block):
                                snake_player.delnode()
                                power_is_overwhelming()
                                break
                        else:
                            continue
                        break
                    else:
                        continue
                    break

        # 显示死亡文字
        isdead = snake_player.isdead()

        if isdead:
            show_text(screen, (300, 200), 'You are Dead!', (227, 29, 18), False, 100)
            show_text(screen, (450, 400), '你的得分是：' + str(scores), (0, 0, 22), False, 30)
            show_text(screen, (400, 500), 'press space to try again...', (0, 0, 22), False, 30)

        # 食物处理 / 吃到+50分
        # 当食物rect与蛇头重合,吃掉 -> Snake增加一个Node
        if laser_build:
            if scale <= 1:
                scale = 1
            else:
                scale -= 0.2
            laser_x = current_laser[0] + (1 - scale) * (BOARD_SIZE // 2)
            laser_y = current_laser[1] + (1 - scale) * (BOARD_SIZE // 2)
            LASER_RECT = int(laser_x), int(laser_y), int(BOARD_SIZE * scale), int(BOARD_SIZE * scale)
            pygame.draw.rect(screen, (136, 0, 21), LASER_RECT, 0)
            if scale == 1:
                laser_complete.append(LASER_RECT)
                laser_build = False
                scale = FOOD_CONV_SIZE
                print("定时器已设置")
                print(order_number)
                pygame.time.set_timer(laser_attack_group[random_laser_poi[order_number]],
                                      lasers_attack_timer[random_laser_poi[order_number]])
                order_number += 1

        if len(laser_complete) != 0:
            for laser_rect in laser_complete:
                pygame.draw.rect(screen, (136, 0, 21), laser_rect, 0)

        if laser_attack_signal_1:

            temp_x = laser_attack_signal_1_start_poi[0] + BOARD_SIZE / 2
            temp_y = laser_attack_signal_1_start_poi[1] + BOARD_SIZE / 2
            t0 = lasers_normal_use[0]
            hold_x = t0[0] + BOARD_SIZE / 2
            hold_y = t0[1] + BOARD_SIZE / 2

            if laser_attack_signal_1_forward == pygame.K_UP:

                if laser_attack_signal_1_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_1_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(laser_attack_signal_1_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(laser_attack_signal_1_y), 4, 15)
                    attack2 = (int(temp_x - 2), int(laser_attack_signal_1_y + 15), 4, 15)
                    attack3 = (int(temp_x - 2), int(laser_attack_signal_1_y + 30), 4, 15)
                    attack4 = (int(temp_x - 2), int(laser_attack_signal_1_y + 45), 4, 20)
                    attack5 = (int(temp_x - 2), int(laser_attack_signal_1_y + 65), 4, 20)
                    attack6 = (int(temp_x - 2), int(laser_attack_signal_1_y + 85), 4, 15)
                    attack7 = (int(temp_x - 2), int(laser_attack_signal_1_y + 100), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER:
                        if not isdead:
                            for body in snake_player.body:
                                for laser in laser_array:
                                    if body.colliderect(laser):
                                        snake_player.delnode()
                                        power_is_overwhelming()
                                        break
                                else:
                                    continue
                                break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_1_y -= int(t3)
                else:
                    laser_attack_signal_1 = False
            if laser_attack_signal_1_forward == pygame.K_DOWN:
                if laser_attack_signal_1_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_1_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(SCREEN_Y - laser_attack_signal_1_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y) - 15, 4, 15)
                    attack2 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y - 30), 4, 15)
                    attack3 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y - 45), 4, 15)
                    attack4 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y - 60), 4, 20)
                    attack5 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y - 80), 4, 20)
                    attack6 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y - 100), 4, 15)
                    attack7 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_1_y - 115), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_1_y -= int(t3)
                else:
                    laser_attack_signal_1 = False
            if laser_attack_signal_1_forward == pygame.K_RIGHT:
                if laser_attack_signal_1_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_1_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(SCREEN_X - laser_attack_signal_1_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(SCREEN_X - laser_attack_signal_1_x) - 15, int(temp_y - 2), 15, 4)
                    attack2 = (int(SCREEN_X - laser_attack_signal_1_x - 30), int(temp_y - 2), 15, 4)
                    attack3 = (int(SCREEN_X - laser_attack_signal_1_x - 45), int(temp_y - 2), 15, 4)
                    attack4 = (int(SCREEN_X - laser_attack_signal_1_x - 60), int(temp_y - 2), 20, 4)
                    attack5 = (int(SCREEN_X - laser_attack_signal_1_x - 80), int(temp_y - 2), 20, 4)
                    attack6 = (int(SCREEN_X - laser_attack_signal_1_x - 100), int(temp_y - 2), 15, 4)
                    attack7 = (int(SCREEN_X - laser_attack_signal_1_x - 115), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_1_x -= int(t3)
                else:
                    laser_attack_signal_1 = False
            if laser_attack_signal_1_forward == pygame.K_LEFT:
                if laser_attack_signal_1_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_1_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(laser_attack_signal_1_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(laser_attack_signal_1_x), int(temp_y - 2), 15, 4)
                    attack2 = (int(laser_attack_signal_1_x + 15), int(temp_y - 2), 15, 4)
                    attack3 = (int(laser_attack_signal_1_x + 30), int(temp_y - 2), 15, 4)
                    attack4 = (int(laser_attack_signal_1_x + 45), int(temp_y - 2), 20, 4)
                    attack5 = (int(laser_attack_signal_1_x + 60), int(temp_y - 2), 20, 4)
                    attack6 = (int(laser_attack_signal_1_x + 85), int(temp_y - 2), 15, 4)
                    attack7 = (int(laser_attack_signal_1_x + 100), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_1_x -= int(t3)
                else:
                    laser_attack_signal_1 = False
            laser_sound.play()
        if laser_attack_signal_2:

            temp_x = laser_attack_signal_2_start_poi[0] + BOARD_SIZE / 2
            temp_y = laser_attack_signal_2_start_poi[1] + BOARD_SIZE / 2
            t0 = lasers_normal_use[1]
            hold_x = t0[0] + BOARD_SIZE / 2
            hold_y = t0[1] + BOARD_SIZE / 2

            if laser_attack_signal_2_forward == pygame.K_UP:

                if laser_attack_signal_2_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_2_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(laser_attack_signal_2_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(laser_attack_signal_2_y), 4, 15)
                    attack2 = (int(temp_x - 2), int(laser_attack_signal_2_y + 15), 4, 15)
                    attack3 = (int(temp_x - 2), int(laser_attack_signal_2_y + 30), 4, 15)
                    attack4 = (int(temp_x - 2), int(laser_attack_signal_2_y + 45), 4, 20)
                    attack5 = (int(temp_x - 2), int(laser_attack_signal_2_y + 65), 4, 20)
                    attack6 = (int(temp_x - 2), int(laser_attack_signal_2_y + 85), 4, 15)
                    attack7 = (int(temp_x - 2), int(laser_attack_signal_2_y + 100), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_2_y -= int(t3)
                else:
                    laser_attack_signal_2 = False
            if laser_attack_signal_2_forward == pygame.K_DOWN:
                if laser_attack_signal_2_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_2_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(SCREEN_Y - laser_attack_signal_2_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y) - 15, 4, 15)
                    attack2 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y - 30), 4, 15)
                    attack3 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y - 45), 4, 15)
                    attack4 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y - 60), 4, 20)
                    attack5 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y - 80), 4, 20)
                    attack6 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y - 100), 4, 15)
                    attack7 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_2_y - 115), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_2_y -= int(t3)
                else:
                    laser_attack_signal_2 = False
            if laser_attack_signal_2_forward == pygame.K_RIGHT:
                if laser_attack_signal_2_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_2_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(SCREEN_X - laser_attack_signal_2_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(SCREEN_X - laser_attack_signal_2_x) - 15, int(temp_y - 2), 15, 4)
                    attack2 = (int(SCREEN_X - laser_attack_signal_2_x - 30), int(temp_y - 2), 15, 4)
                    attack3 = (int(SCREEN_X - laser_attack_signal_2_x - 45), int(temp_y - 2), 15, 4)
                    attack4 = (int(SCREEN_X - laser_attack_signal_2_x - 60), int(temp_y - 2), 20, 4)
                    attack5 = (int(SCREEN_X - laser_attack_signal_2_x - 80), int(temp_y - 2), 20, 4)
                    attack6 = (int(SCREEN_X - laser_attack_signal_2_x - 100), int(temp_y - 2), 15, 4)
                    attack7 = (int(SCREEN_X - laser_attack_signal_2_x - 115), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_2_x -= int(t3)
                else:
                    laser_attack_signal_2 = False
            if laser_attack_signal_2_forward == pygame.K_LEFT:
                if laser_attack_signal_2_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_2_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(laser_attack_signal_2_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(laser_attack_signal_2_x), int(temp_y - 2), 15, 4)
                    attack2 = (int(laser_attack_signal_2_x + 15), int(temp_y - 2), 15, 4)
                    attack3 = (int(laser_attack_signal_2_x + 30), int(temp_y - 2), 15, 4)
                    attack4 = (int(laser_attack_signal_2_x + 45), int(temp_y - 2), 20, 4)
                    attack5 = (int(laser_attack_signal_2_x + 60), int(temp_y - 2), 20, 4)
                    attack6 = (int(laser_attack_signal_2_x + 85), int(temp_y - 2), 15, 4)
                    attack7 = (int(laser_attack_signal_2_x + 100), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_2_x -= int(t3)
                else:
                    laser_attack_signal_2 = False
            laser_sound.play()
        if laser_attack_signal_3:

            temp_x = laser_attack_signal_3_start_poi[0] + BOARD_SIZE / 2
            temp_y = laser_attack_signal_3_start_poi[1] + BOARD_SIZE / 2
            t0 = lasers_normal_use[2]
            hold_x = t0[0] + BOARD_SIZE / 2
            hold_y = t0[1] + BOARD_SIZE / 2

            if laser_attack_signal_3_forward == pygame.K_UP:

                if laser_attack_signal_3_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_3_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(laser_attack_signal_3_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(laser_attack_signal_3_y), 4, 15)
                    attack2 = (int(temp_x - 2), int(laser_attack_signal_3_y + 15), 4, 15)
                    attack3 = (int(temp_x - 2), int(laser_attack_signal_3_y + 30), 4, 15)
                    attack4 = (int(temp_x - 2), int(laser_attack_signal_3_y + 45), 4, 20)
                    attack5 = (int(temp_x - 2), int(laser_attack_signal_3_y + 65), 4, 20)
                    attack6 = (int(temp_x - 2), int(laser_attack_signal_3_y + 85), 4, 15)
                    attack7 = (int(temp_x - 2), int(laser_attack_signal_3_y + 100), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_3_y -= int(t3)
                else:
                    laser_attack_signal_3 = False
            if laser_attack_signal_3_forward == pygame.K_DOWN:
                if laser_attack_signal_3_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_3_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(SCREEN_Y - laser_attack_signal_3_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y) - 15, 4, 15)
                    attack2 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y - 30), 4, 15)
                    attack3 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y - 45), 4, 15)
                    attack4 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y - 60), 4, 20)
                    attack5 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y - 80), 4, 20)
                    attack6 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y - 100), 4, 15)
                    attack7 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_3_y - 115), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_3_y -= int(t3)
                else:
                    laser_attack_signal_3 = False
            if laser_attack_signal_3_forward == pygame.K_RIGHT:
                if laser_attack_signal_3_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_3_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(SCREEN_X - laser_attack_signal_3_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(SCREEN_X - laser_attack_signal_3_x) - 15, int(temp_y - 2), 15, 4)
                    attack2 = (int(SCREEN_X - laser_attack_signal_3_x - 30), int(temp_y - 2), 15, 4)
                    attack3 = (int(SCREEN_X - laser_attack_signal_3_x - 45), int(temp_y - 2), 15, 4)
                    attack4 = (int(SCREEN_X - laser_attack_signal_3_x - 60), int(temp_y - 2), 20, 4)
                    attack5 = (int(SCREEN_X - laser_attack_signal_3_x - 80), int(temp_y - 2), 20, 4)
                    attack6 = (int(SCREEN_X - laser_attack_signal_3_x - 100), int(temp_y - 2), 15, 4)
                    attack7 = (int(SCREEN_X - laser_attack_signal_3_x - 115), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_3_x -= int(t3)
                else:
                    laser_attack_signal_3 = False
            if laser_attack_signal_3_forward == pygame.K_LEFT:
                if laser_attack_signal_3_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_3_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(laser_attack_signal_3_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(laser_attack_signal_3_x), int(temp_y - 2), 15, 4)
                    attack2 = (int(laser_attack_signal_3_x + 15), int(temp_y - 2), 15, 4)
                    attack3 = (int(laser_attack_signal_3_x + 30), int(temp_y - 2), 15, 4)
                    attack4 = (int(laser_attack_signal_3_x + 45), int(temp_y - 2), 20, 4)
                    attack5 = (int(laser_attack_signal_3_x + 60), int(temp_y - 2), 20, 4)
                    attack6 = (int(laser_attack_signal_3_x + 85), int(temp_y - 2), 15, 4)
                    attack7 = (int(laser_attack_signal_3_x + 100), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_3_x -= int(t3)
                else:
                    laser_attack_signal_3 = False
            laser_sound.play()
        if laser_attack_signal_4:

            temp_x = laser_attack_signal_4_start_poi[0] + BOARD_SIZE / 2
            temp_y = laser_attack_signal_4_start_poi[1] + BOARD_SIZE / 2
            t0 = lasers_normal_use[3]
            hold_x = t0[0] + BOARD_SIZE / 2
            hold_y = t0[1] + BOARD_SIZE / 2

            if laser_attack_signal_4_forward == pygame.K_UP:

                if laser_attack_signal_4_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_4_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(laser_attack_signal_4_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(laser_attack_signal_4_y), 4, 15)
                    attack2 = (int(temp_x - 2), int(laser_attack_signal_4_y + 15), 4, 15)
                    attack3 = (int(temp_x - 2), int(laser_attack_signal_4_y + 30), 4, 15)
                    attack4 = (int(temp_x - 2), int(laser_attack_signal_4_y + 45), 4, 20)
                    attack5 = (int(temp_x - 2), int(laser_attack_signal_4_y + 65), 4, 20)
                    attack6 = (int(temp_x - 2), int(laser_attack_signal_4_y + 85), 4, 15)
                    attack7 = (int(temp_x - 2), int(laser_attack_signal_4_y + 100), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_4_y -= int(t3)
                else:
                    laser_attack_signal_4 = False
            if laser_attack_signal_4_forward == pygame.K_DOWN:
                if laser_attack_signal_4_y > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_Y_DIVIDE - laser_attack_signal_4_y / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(temp_x), int(SCREEN_Y - laser_attack_signal_4_y)), 3)

                    laser_array = []
                    attack1 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y) - 15, 4, 15)
                    attack2 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y - 30), 4, 15)
                    attack3 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y - 45), 4, 15)
                    attack4 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y - 60), 4, 20)
                    attack5 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y - 80), 4, 20)
                    attack6 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y - 100), 4, 15)
                    attack7 = (int(temp_x - 2), int(SCREEN_Y - laser_attack_signal_4_y - 115), 4, 10)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_4_y -= int(t3)
                else:
                    laser_attack_signal_4 = False
            if laser_attack_signal_4_forward == pygame.K_RIGHT:
                if laser_attack_signal_4_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_4_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(SCREEN_X - laser_attack_signal_4_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(SCREEN_X - laser_attack_signal_4_x) - 15, int(temp_y - 2), 15, 4)
                    attack2 = (int(SCREEN_X - laser_attack_signal_4_x - 30), int(temp_y - 2), 15, 4)
                    attack3 = (int(SCREEN_X - laser_attack_signal_4_x - 45), int(temp_y - 2), 15, 4)
                    attack4 = (int(SCREEN_X - laser_attack_signal_4_x - 60), int(temp_y - 2), 20, 4)
                    attack5 = (int(SCREEN_X - laser_attack_signal_4_x - 80), int(temp_y - 2), 20, 4)
                    attack6 = (int(SCREEN_X - laser_attack_signal_4_x - 100), int(temp_y - 2), 15, 4)
                    attack7 = (int(SCREEN_X - laser_attack_signal_4_x - 115), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_4_x -= int(t3)
                else:
                    laser_attack_signal_4 = False
            if laser_attack_signal_4_forward == pygame.K_LEFT:
                if laser_attack_signal_4_x > 0:
                    laser_start_x = int(hold_x)
                    laser_start_y = int(hold_y)
                    default = 8
                    t1 = (math.pow(SCREEN_X_DIVIDE - laser_attack_signal_4_x / 100, 5))
                    pygame.draw.line(screen, (255, 51, 0), (laser_start_x, laser_start_y),
                                     (int(laser_attack_signal_4_x), int(temp_y)), 3)

                    laser_array = []
                    attack1 = (int(laser_attack_signal_4_x), int(temp_y - 2), 15, 4)
                    attack2 = (int(laser_attack_signal_4_x + 15), int(temp_y - 2), 15, 4)
                    attack3 = (int(laser_attack_signal_4_x + 30), int(temp_y - 2), 15, 4)
                    attack4 = (int(laser_attack_signal_4_x + 45), int(temp_y - 2), 20, 4)
                    attack5 = (int(laser_attack_signal_4_x + 60), int(temp_y - 2), 20, 4)
                    attack6 = (int(laser_attack_signal_4_x + 85), int(temp_y - 2), 15, 4)
                    attack7 = (int(laser_attack_signal_4_x + 100), int(temp_y - 2), 10, 4)
                    pygame.draw.rect(screen, (255, 0, 0), attack1, 0)
                    pygame.draw.rect(screen, (255, 43, 0), attack2, 0)
                    pygame.draw.rect(screen, (255, 85, 0), attack3, 0)
                    pygame.draw.rect(screen, (255, 128, 0), attack4, 0)
                    pygame.draw.rect(screen, (255, 170, 0), attack5, 0)
                    pygame.draw.rect(screen, (255, 213, 0), attack6, 0)
                    pygame.draw.rect(screen, (255, 255, 0), attack7, 0)
                    laser_array.append(attack1)
                    laser_array.append(attack2)
                    laser_array.append(attack3)
                    laser_array.append(attack4)
                    laser_array.append(attack5)
                    laser_array.append(attack6)
                    laser_array.append(attack7)

                    if not POWER and not isdead:
                        for body in snake_player.body:
                            for laser in laser_array:
                                if body.colliderect(laser):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

                    t2 = t1 / math.pow(10, 2)
                    t3 = (t2 + default * (1 + t1 / 1200))
                    laser_attack_signal_4_x -= int(t3)
                else:
                    laser_attack_signal_4 = False
            laser_sound.play()
        # laser_check(POWER, laser_attack_signal_2, laser_attack_signal_2_forward, laser_attack_signal_2_start_poi,
        #             laser_attack_signal_2_x, laser_attack_signal_2_y, lasers_normal_use, screen, snake_player)
        # laser_check(POWER, laser_attack_signal_3, laser_attack_signal_3_forward, laser_attack_signal_3_start_poi,
        #             laser_attack_signal_3_x, laser_attack_signal_3_y, lasers_normal_use, screen, snake_player)
        # laser_check(POWER, laser_attack_signal_4, laser_attack_signal_4_forward, laser_attack_signal_4_start_poi,
        #             laser_attack_signal_4_x, laser_attack_signal_4_y, lasers_normal_use, screen, snake_player)

        #
        FOOD_RECT = food.rect

        if FOOD_RECT.colliderect(snake_player.body[0]):
            food.remove()
            snake_player.addnode()

        # # 食物投递
        food.set()
        pygame.draw.rect(screen, (255, 165, 0), FOOD_RECT, 0)
        # 激光攻击
        # if scale == 1:

        # show_text(screen, (50, 500), 'Scores: ' + str(scores), (223, 223, 223))

        bullet_line.set()

        if can_bullet_attack_1:
            if not final_bullet_1:
                t_bullet = []
                if bullet_line_y_count < len(bullet_line.all_pos_verti):
                    for range in bullet_line.all_pos_hori[::8]:
                        rect = pygame.Rect(range, bullet_line.all_pos_verti[bullet_line_y_count], BOARD_SIZE,
                                           BOARD_SIZE)
                        t_bullet.append(rect)
                        pygame.draw.rect(screen, (105, 105, 105), rect, 0)

                    bullet_line_y_count += 1

                if bullet_line_y_count < len(bullet_line.all_pos_verti):
                    for range in bullet_line.all_pos_hori[4::8]:
                        rect = pygame.Rect(range, SCREEN_Y - bullet_line.all_pos_verti[bullet_line_y_count], BOARD_SIZE,
                                           BOARD_SIZE)
                        t_bullet.append(rect)
                        pygame.draw.rect(screen, (105, 105, 105), rect, 0)

                if bullet_line_y_count >= len(bullet_line.all_pos_verti) and bullet_line_x_count < len(
                        bullet_line.all_pos_hori):
                    for range in bullet_line.all_pos_verti[::4]:
                        rect = pygame.Rect(bullet_line.all_pos_hori[bullet_line_x_count], range, BOARD_SIZE, BOARD_SIZE)
                        t_bullet.append(rect)
                        pygame.draw.rect(screen, (105, 105, 105), rect, 0)

                    bullet_line_x_count += 1

                if bullet_line_y_count >= len(bullet_line.all_pos_verti) and bullet_line_x_count < len(
                        bullet_line.all_pos_hori):
                    for range in bullet_line.all_pos_verti[2::4]:
                        x = SCREEN_X - bullet_line.all_pos_hori[bullet_line_x_count]
                        y = range
                        rect = pygame.Rect(x, y, BOARD_SIZE, BOARD_SIZE)
                        t_bullet.append(rect)
                        pygame.draw.rect(screen, (105, 105, 105), rect, 0)

                if not POWER:
                    if not isdead:
                        for body in snake_player.body:
                            for bullet in t_bullet:
                                if body.colliderect(bullet):
                                    snake_player.delnode()
                                    power_is_overwhelming()
                                    break
                            else:
                                continue
                            break

        if bullet_line_x_count >= len(bullet_line.all_pos_hori):
            final_bullet_1 = True
            bullet_line_y_count = 0
            bullet_line_x_count = 0

        if final_bullet_1:
            t_bullet = []
            if bullet_line_y_count < len(bullet_line.all_pos_verti):
                for range in bullet_line.all_pos_hori[::8]:
                    rect = (range, bullet_line.all_pos_verti[bullet_line_y_count], BOARD_SIZE, BOARD_SIZE)
                    pygame.draw.rect(screen, (169, 169, 169), rect, 0)
                    t_bullet.append(rect)

                bullet_line_y_count += 1

            if bullet_line_y_count < len(bullet_line.all_pos_verti):
                for range in bullet_line.all_pos_hori[4::8]:
                    rect = (range, SCREEN_Y - bullet_line.all_pos_verti[bullet_line_y_count], BOARD_SIZE, BOARD_SIZE)
                    pygame.draw.rect(screen, (169, 169, 169), rect, 0)
                    t_bullet.append(rect)

            if bullet_line_x_count < len(
                    bullet_line.all_pos_hori):
                for range in bullet_line.all_pos_verti[::4]:
                    rect = (bullet_line.all_pos_hori[bullet_line_x_count], range, BOARD_SIZE, BOARD_SIZE)
                    pygame.draw.rect(screen, (169, 169, 169), rect, 0)
                    t_bullet.append(rect)

                bullet_line_x_count += 1

            if bullet_line_x_count < len(bullet_line.all_pos_hori):
                for range in bullet_line.all_pos_verti[2::4]:
                    x = SCREEN_X - bullet_line.all_pos_hori[bullet_line_x_count]
                    y = range
                    rect = (x, y, BOARD_SIZE, BOARD_SIZE)
                    pygame.draw.rect(screen, (169, 169, 169), rect, 0)
                    t_bullet.append(rect)

            if bullet_line_x_count >= len(bullet_line.all_pos_hori):
                final_bullet_1 = False
                bullet_line_y_count = 0
                bullet_line_x_count = 0
                can_bullet_attack_1 = False

            if not POWER:
                if not isdead:
                    for body in snake_player.body:
                        for bullet in t_bullet:
                            if body.colliderect(bullet):
                                snake_player.delnode()
                                power_is_overwhelming()
                                break
                        else:
                            continue
                        break

        pygame.display.update()
        clock.tick(FPS)


if __name__ == '__main__':
    main()
